package com.lc.admin.web;

import com.lc.admin.base.PageResponse;
import com.lc.admin.base.ResponseResult;
import com.lc.admin.bean.NursingLevel;
import com.lc.admin.constants.PagerConstants;
import com.lc.admin.service.NursingLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/nursing_level")
//@Api(tags="护理等级接口")
public class NursingLevelWeb {

    @Autowired
    NursingLevelService nursingLevelService;

    /**
     * 分页条件查询接口
     * @return
     */
    @GetMapping("/list")
//    @ApiOperation("护理等级分页条件查询")
    public ResponseResult<PageResponse<NursingLevel>> list(
           @RequestParam(defaultValue = PagerConstants.PAGE_STR) Integer page,
           @RequestParam(defaultValue = PagerConstants.PAGE_SIZE_STR) Integer pageSize,
           String name,
           Integer status
    ){
        PageResponse<NursingLevel> pageResponse = nursingLevelService.list(page,pageSize,name,status);
        return ResponseResult.success(pageResponse);
    }

    // 需要一个文件上传接口，传到阿里云服务器oss   会返回一个图片在阿里云的存储地址

    @PostMapping("/save")
//    @ApiOperation("新增护理等级")
    public ResponseResult save(@RequestBody NursingLevel NursingLevel) {
        nursingLevelService.save(NursingLevel);

        return ResponseResult.success();
    }

    @GetMapping("/findById/{id}")
//    @ApiOperation("根据id查询护理等级")
    public ResponseResult<NursingLevel> findById(@PathVariable("id") Long id) {
        NursingLevel NursingLevel = nursingLevelService.findById(id);
        return ResponseResult.success(NursingLevel);
    }

    @PutMapping("/edit")
    public ResponseResult edit(@RequestBody NursingLevel NursingLevel) {
        nursingLevelService.edit(NursingLevel);
        return ResponseResult.success();
    }

    @GetMapping("/enable/{id}/{status}")
    public ResponseResult enable(
            @PathVariable("id") Long id,
            @PathVariable("status") Integer status) {
        nursingLevelService.enable(id,status);
        return ResponseResult.success();
    }

    @DeleteMapping("/enable/{id}")
    public ResponseResult del(@PathVariable("id") Integer id) {
        nursingLevelService.del(id);
        return ResponseResult.success();
    }


}
